<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="12">
        <el-card class="card-network">
          <div slot="header" class="clearfix">
            <span>网络</span>
            <el-button style="float: right; padding: 3px 0" type="text">操作</el-button>
          </div>
          <div id="chart-network" :style="{height: '200px'}"></div>
          <div>
            <el-row>
              <el-col :span="16">
                <div class="temperature">
                  <p class="text-semibold">温度</p>
                  <div>
                    <span class="text-2x text-semibold text-nowrap text-main"><svg-icon icon-class="temperature"></svg-icon>30.0</span>
                  </div>
                  <div>
                    <p class="mar-no">°C</p>
                  </div>
                </div>
                <div class="pad-btm">
                  <p class="text-semibold text-main mar-no">今日小贴士</p>
                  <small>一个美好的宁静已经占据了我的整个灵魂，就像我全心全意享受春天的美好早晨。</small>
                </div>
              </el-col>
              <el-col :span="8">
                <p>宽带使用</p>
                <ul>
                  <li>
                    <div>
                      <div>
                        <span>75.9</span>
                      </div>
                      <div>
                        <p>Mbps</p>
                      </div>
                    </div>
                  </li>
                </ul>
              </el-col>
            </el-row>
          </div>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-card class="card-storage">
              <div>
                <svg-icon icon-class="storage"></svg-icon> 硬盘使用情况
                <p class="mar-no"><span class="pull-right text-bold">100Gb</span>可用</p>
                <p class="mar-no"><span class="pull-right text-bold">50Gb</span>已用</p>
              </div>
            </el-card>
          </el-col>
          <el-col :span="12">
            <el-card class="card-order">
              <div>
                <svg-icon icon-class="sales"></svg-icon> 订单
                <p class="mar-no"><span class="pull-right text-bold">$1000</span>今日</p>
                <p class="mar-no"><span class="pull-right text-bold">$1200</span>过去7天</p>
              </div>
            </el-card>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-card class="card-profit">
              <div>
                <svg-icon icon-class="order"></svg-icon> 收益
                <p class="mar-no"><span class="pull-right text-bold">$1000</span>今日</p>
                <p class="mar-no"><span class="pull-right text-bold">$1200</span>过去7天</p>
              </div>
            </el-card>
          </el-col>
          <el-col :span="12">
            <el-card class="card-task">
              <div>
                <svg-icon icon-class="task"></svg-icon> 任务
                <p class="mar-no"><span class="pull-right text-bold">$1000</span>今日</p>
                <p class="mar-no"><span class="pull-right text-bold">$1200</span>过去7天</p>
              </div>
            </el-card>
          </el-col>
        </el-row>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import 'echarts/theme/macarons.js'
let echarts = require('echarts/lib/echarts')
// 引入柱状图组件
require('echarts/lib/chart/line')
// 引入提示框和title组件
require('echarts/lib/component/tooltip')
require('echarts/lib/component/title')

export default {
  name: 'dashboard',
  data () {
    return {
    }
  },
  mounted () {
    this.drawLine()
  },
  methods: {
    drawLine () {
      // 基于准备好的dom，初始化echarts实例
      let networkChart = echarts.init(document.getElementById('chart-network'), 'macarons')
      // 绘制图表
      networkChart.setOption({
        tooltip: {},
        xAxis: {
          data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
        },
        yAxis: {},
        series: [
          {
            name: '邮件营销',
            type: 'line',
            stack: '总量',
            areaStyle: {},
            data: [120, 132, 101, 134, 90, 230, 210]
          },
          {
            name: '联盟广告',
            type: 'line',
            stack: '总量',
            areaStyle: {},
            data: [220, 182, 191, 234, 290, 330, 310]
          },
          {
            name: '视频广告',
            type: 'line',
            stack: '总量',
            areaStyle: {},
            data: [150, 232, 201, 154, 190, 330, 410]
          },
          {
            name: '直接访问',
            type: 'line',
            stack: '总量',
            areaStyle: {normal: {}},
            data:[320, 332, 301, 334, 390, 330, 320]
          },
          {
            name: '搜索引擎',
            type: 'line',
            stack: '总量',
            label: {
              normal: {
                show: true,
                position: 'top'
              }
            },
            areaStyle: {normal: {}},
            data: [820, 932, 901, 934, 1290, 1330, 1320]
          }
        ]
      })
    }
  }

}
</script>

<style scoped>
  .card-border{
    border: 1px solid transparent;
    border-radius: 4px;
    -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
    box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
  }
  .card-network{
    height: 320px;
  }
  .card-storage{
    height: 150px;
    background-color: #8bc34a;
    border-color: #8bc34a;
    color: #fff;
  }
  .card-order{
    height: 150px;
    background-color: #46A3FF;
    border-color: #46A3FF;
    color: #fff;
  }
  .card-profit{
    height: 150px;
    margin-top: 20px;
    background-color: #ba68c8;
    border-color: #ba68c8;
    color: #fff;
  }
  .card-task{
    height: 150px;
    margin-top: 20px;
    background-color: #ffa726;
    border-color: #ffa726;
    color: #fff;
  }
</style>
